import json
import os


# 解析data中的数据，形成参数化
def analyze_data():

    # 获取当前脚本文件的绝对路径
    current_file = os.path.abspath(__file__)
    # 获取当前脚本所在目录的路径
    current_dir = os.path.dirname(current_file)

    # 获取项目的根路径（假设项目根目录是包含当前文件的上层目录）
    project_root = os.path.dirname(current_dir)

    print("项目根路径:", project_root)

    windows_path = project_root + '\data\login_data.json'

    # python_path = os.path.normpath(windows_path)

    with open(file=windows_path.replace("\\", '/'), mode="r", encoding='utf-8') as f:
    # with open('../../data/login_data.json', "r", encoding='utf-8') as f:
    # with open(r'D:\python_project\UI_POpytest_Bibili_xiaobei\data\login_data.json', "r", encoding='utf-8') as f:
        list_data = []
        dict_data = json.load(f)
        # print(dict_data)
        for data in dict_data.values():
            # print(data)
            list_data.append(data)
        return list_data




